﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

/// <summary>
/// 一个技能由多个触发器组成
/// </summary>
public class SkillInstance
{
    public bool m_bIsUsed = false;
    public List<ISkillTrigger> m_SkillTriggers = new List<ISkillTrigger>();

    public SkillInstance() { }
    public SkillInstance(SkillInstance other)
    {
        foreach (var trigger in other.m_SkillTriggers)
        {
            m_SkillTriggers.Add(trigger.Clone());
        }
    }

    /// <summary>
    /// 技能执行这里有待商榷的。 他的时间判断该放在这一层，还是上一层，还是trigger层呢
    /// 这个技能的其他额外信息如何处理
    /// </summary>
    /// <param name="instance"></param>
    /// <param name="curtime"></param>
    public void Execute(ISkillCore instance, float curtime)
    {
        foreach (ISkillTrigger temp in m_SkillTriggers)
        {
            temp.Execute(instance, curtime);
        }
    }

    public void Reset()
    {
        foreach(var trigger in m_SkillTriggers)
        {
            trigger.Reset();
        }
    }

    public int GetTriggerCount(string typeName)
    {
        int count = 0;
        foreach(var trigger in m_SkillTriggers)
        {
            if (trigger.GetTypeName() == typeName)
                ++count;
        }
        return count;
    }
}
